/**
 *
 * @author 
 *
 */
class PHBView extends eui.Component{
    
    public myPM:eui.Label;
    private btn_sy:eui.Image;
    private sollBox:eui.Scroller;
    private List1:eui.Group;
    
    private static _instance: PHBView;
    public static getInstance(): PHBView {
        if(PHBView._instance == null) {
            PHBView._instance = new PHBView();
        }
        PHBView._instance.List1.scrollV = 0;
        return PHBView._instance;
    }
    
	public constructor() {
        super();
        this.skinName = "resource/skins/PHBViewSkin.exml";
	}
	public createChildren() {
        super.createChildren();
        this.sollBox.viewport = this.List1;
        this.btn_sy.addEventListener(egret.TouchEvent.TOUCH_TAP,this.openSY,this);
        this.init();
    }
    
    private openSY(ev:egret.TouchEvent){
        if(Main.getInstance().contains(PHBView.getInstance())) {
            PHBView.getInstance().parent.removeChild(PHBView.getInstance());
        }
        Main.getInstance().addChild(ShouYeView.getInstance());
        ShouYeView.getInstance().initM()
    }
    
    private init() {
        egret.Tween.get(this,{ loop: true }).to({ t: Math.PI * 2 },800);
    }
    private _t: number = 0;
    get t(): number { return this._t; }
    set t(value: number) {
        this._t = value;
        this.btn_sy.scaleX = Math.sin(value) * 0.05 + 1;
        this.btn_sy.scaleY = Math.sin(value - Math.PI / 2) * 0.05 + 1;
    }
    
    public setData(data:any[]){
        this.List1.removeChildren();
        for(var i:number = 0;i<20;i++){
            var item:PHBItemView = new PHBItemView();
            if(i==0){
                item.ranking.textColor = 0xe41420;
                item.ranking.text = "第一名";
            }else if(i==1){
                item.ranking.textColor = 0xff9414;
                item.ranking.text = "第二名";
            }else if(i==2){
                item.ranking.textColor = 0xf7a57a;
                item.ranking.text = "第三名";
            }else if(i==3){
                item.ranking.text = "第四名";
            } else if(i == 4) {
                item.ranking.text = "第五名";
            } else if(i == 5) {
                item.ranking.text = "第六名";
            } else if(i == 6) {
                item.ranking.text = "第七名";
            } else if(i == 7) {
                item.ranking.text = "第八名";
            } else if(i == 8) {
                item.ranking.text = "第九名";
            } else if(i == 9) {
                item.ranking.text = "第十名";
            } else if(i == 10) {
                item.ranking.text = "第十一名";
            } else if(i == 11) {
                item.ranking.text = "第十二名";
            } else if(i == 12) {
                item.ranking.text = "第十三名";
            } else if(i == 13) {
                item.ranking.text = "第十四名";
            } else if(i == 14) {
                item.ranking.text = "第十五名";
            } else if(i == 15) {
                item.ranking.text = "第十六名";
            } else if(i == 16) {
                item.ranking.text = "第十七名";
            } else if(i == 17) {
                item.ranking.text = "第十八名";
            } else if(i == 18) {
                item.ranking.text = "第十九名";
            } else if(i == 19) {
                item.ranking.text = "第二十名";
            }
            console.log(data[i].nickname);
            item.nickName.text = data[i].nickname;
            if(data[i].phone.length==11){
                item.phoneNumber.text = data[i].phone.replace(/\d{4}(?=\d{4}$)/,"****");
            }else{
                 item.phoneNumber.text = "";
            }
            item.score.text = data[i].score+"分";
            this.List1.addChild(item);
            item.y = i*57;
        }
    } 
	
}
